﻿Ext.namespace('FantastPlatform', 'FantastPlatform.UI');
FantastPlatform.UI.AreaCaseSearch = function (config) {
    Ext.apply(this, config);
    var fiveCase = new Ext.form.CheckboxGroup({
        fieldLabel: '五类案件',
        name: 'fiveCase',
        hiddenName: 'fiveCase',
        displayField: 'Name',
        mode: 'remote',
        valueField: 'Id',
        triggerAction: 'all',
        blankText: '请选案件用途',
        columns: 2,
        items: [
                   { id: 'rscase', boxLabel: '入室盗窃案', inputValue: '入室盗窃案' },
                   { id: 'dqcase', boxLabel: '盗窃汽车案', inputValue: '盗窃汽车案' },
                   { id: 'qjcase', boxLabel: '抢劫案', inputValue: '抢劫案' },
                   { id: 'qdcase', boxLabel: '抢夺案', inputValue: '抢夺案' },
                   { id: 'zpcase', boxLabel: '诈骗案', inputValue: '诈骗案'}]

    });
    var area = new Ext.form.ComboBox({
        fieldLabel: '分类单位',
        store: new Ext.data.SimpleStore({
            fields: ['Ttime', 'Ttext'],
            data: [
                                    ['Station', '派出所'],
                                    ['ResponsibilityArea', '责任区'],
                                    ['Street', '街道']
                                            ]
        }),
        name: 'Ttime',
        value: ' --- 请选择 --- ',
        id: 'module',
        mode: 'local',
        valueField: 'Ttime',
        triggerAction: 'all',
        displayField: 'Ttext',
        readOnly: true,
        width: 280
    });
    this.items = [{
        layout: 'column',
        border: false,
        labelSeparator: '：',
        items: [{
            columnWidth: 0.5,
            layout: 'form',
            border: false,
            items: [new FantastPlatform.UI.DateField({
                fieldLabel: '时间段',
                name: 'StartTime',
                format: 'Y年m月d日',
                width: 150,
                dateConfig: {}
            })]
        }, {
            columnWidth: 0.5,
            layout: 'form',
            border: false,
            labelSeparator: '——',
            items: [new FantastPlatform.UI.DateField({
                fieldLabel: '',
                name: 'EndTime',
                format: 'Y年m月d日',
                width: 150,
                dateConfig: {}
            })]
        }, {
            columnWidth: 1,
            border: false,
            layout: 'form',
            items: [fiveCase]
        }, {
            columnWidth: 1,
            border: false,
            layout: 'form',
            items: [area]
        }]
    }];
    FantastPlatform.UI.AreaCaseSearch.superclass.constructor.call(this, {
        bodyStyle: 'padding-top:25px',
        collapsible: true,
        labelAlign: 'right',
        buttonAlign: 'center',
        autoScroll: false
    });
};
Ext.extend(FantastPlatform.UI.AreaCaseSearch, Ext.form.FormPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.AreaCaseSearch.superclass.onRender.call(this, ct, position);
    },
    submitSearchFormJson: function (form, grid, sender, data) {
        if (form.form.isValid()) {

            var dataStr = Ext.util.JSON.encode(form.form.getValues());
            grid.store.baseParams = {
                data: dataStr
            }
            grid.store.removeAll();
            grid.store.proxy.conn = { method: 'post', url: form.url };
            grid.store.load({ params: { start: 0, limit: grid.paperBar.getPageNumber(), dir: '', sort: '', data: dataStr} });
            if (sender)
                sender.close();

        }
    }

});